package com.kiki.recommendations.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.kiki.recommendations.domain.RecommendationsVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.kiki.common.annotation.Log;
import com.kiki.common.core.controller.BaseController;
import com.kiki.common.core.domain.AjaxResult;
import com.kiki.common.enums.BusinessType;
import com.kiki.recommendations.domain.Recommendations;
import com.kiki.recommendations.service.IRecommendationsService;
import com.kiki.common.utils.poi.ExcelUtil;
import com.kiki.common.core.page.TableDataInfo;


/**
 * 推荐结果Controller
 * 
 * @author 林志毅
 * @date 2025-04-25
 */
@RestController
@RequestMapping("/recommendations/recommendations")
public class RecommendationsController extends BaseController
{
    @Autowired
    private IRecommendationsService recommendationsService;

    /**
     * 查询推荐结果列表
     */
    @PreAuthorize("@ss.hasPermi('recommendations:recommendations:list')")
    @GetMapping("/list")
    public List<RecommendationsVo> list(Recommendations recommendations)
    {
        return recommendationsService.selectRecommendationsList(recommendations);
    }

//    /**
//     * 导出推荐结果列表
//     */
//    @PreAuthorize("@ss.hasPermi('recommendations:recommendations:export')")
//    @Log(title = "推荐结果", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Recommendations recommendations)
//    {
//        List<Recommendations> list = recommendationsService.selectRecommendationsList(recommendations);
//        ExcelUtil<Recommendations> util = new ExcelUtil<Recommendations>(Recommendations.class);
//        util.exportExcel(response, list, "推荐结果数据");
//    }

    /**
     * 获取推荐结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('recommendations:recommendations:query')")
    @GetMapping(value = "/{recId}")
    public AjaxResult getInfo(@PathVariable("recId") Long recId)
    {
        return success(recommendationsService.selectRecommendationsByRecId(recId));
    }

    /**
     * 新增推荐结果
     */
    @PreAuthorize("@ss.hasPermi('recommendations:recommendations:add')")
    @Log(title = "推荐结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Recommendations recommendations)
    {
        return toAjax(recommendationsService.insertRecommendations(recommendations));
    }

    /**
     * 修改推荐结果
     */
    @PreAuthorize("@ss.hasPermi('recommendations:recommendations:edit')")
    @Log(title = "推荐结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Recommendations recommendations)
    {
        return toAjax(recommendationsService.updateRecommendations(recommendations));
    }

    /**
     * 删除推荐结果
     */
    @PreAuthorize("@ss.hasPermi('recommendations:recommendations:remove')")
    @Log(title = "推荐结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recIds}")
    public AjaxResult remove(@PathVariable Long[] recIds)
    {
        return toAjax(recommendationsService.deleteRecommendationsByRecIds(recIds));
    }
}
